package com.ssy.lingxi.order.handler.validator;

import com.ssy.lingxi.order.handler.annotation.BigDecimalStringAnnotation;
import com.ssy.lingxi.order.handler.annotation.OrderIdsAnnotation;
import com.ssy.lingxi.order.utils.NumberUtil;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.math.BigDecimal;
import java.util.List;

/**
 * 订单Id列表校验注解验证类
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-17
 */
public class OrderIdsValidator implements ConstraintValidator<OrderIdsAnnotation, List<Long>> {
    @Override
    public boolean isValid(List<Long> value, ConstraintValidatorContext context) {
        return !CollectionUtils.isEmpty(value) && value.stream().allMatch(NumberUtil::notNullAndPositive) && value.size() == value.stream().distinct().count();
    }
}
